<template>
  <div class="t-background" id="t-background"></div>
</template>

<script>
  export default {
    name: 't-background',
    mounted() {
      const defaultBackgroundUrl = window.localStorage.getItem('default-background-url');
      if (!defaultBackgroundUrl) {
        this.$http.request({
          url: 'api/pictures/actions/default',
          method: 'get',
        }).then((response) => {
          this.$el.style.backgroundImage = `url(${response.data.url})`;
          window.localStorage.setItem('default-background-url', response.data.url);
        }).catch(() => {
        });
      } else {
        this.$el.style.backgroundImage = `url(${defaultBackgroundUrl})`;
      }
    },
  };
</script>